﻿<Window 
    x:Class="KBS.FamilyLines.MainWindow"        
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:KBS.FamilyLinesLib="clr-namespace:KBS.FamilyLinesLib;assembly=FamilyShowLib"
    xmlns:properties="clr-namespace:KBS.FamilyLines.Properties"
    xmlns:local="clr-namespace:KBS.FamilyLines" 
    xmlns:Controls="clr-namespace:KBS.FamilyLines.Controls"
    mc:Ignorable="d"
    WindowStartupLocation="CenterScreen" 
    Style="{DynamicResource MainWindowStyle}"
        >
    <Window.Resources>
        <!-- Animation for showing the Person Info control -->
        <Storyboard
            x:Key="ShowPersonInfo" 
            Completed="ShowPersonInfo_StoryboardCompleted"
                >
            <DoubleAnimationUsingKeyFrames
                BeginTime="00:00:00" 
                Storyboard.TargetName="PersonInfoControl" 
                Storyboard.TargetProperty="(UIElement.Opacity)"
                    >
                <SplineDoubleKeyFrame
                    KeyTime="00:00:00"
                    Value="0"
                        />
                <SplineDoubleKeyFrame
                    KeyTime="00:00:00.3000000" 
                    Value="1"
                        />
            </DoubleAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames
                BeginTime="00:00:00" 
                Storyboard.TargetName="PersonInfoControl" 
                Storyboard.TargetProperty="(UIElement.Visibility)"
                    >
                <DiscreteObjectKeyFrame
                    KeyTime="00:00:00" 
                    Value="{x:Static Visibility.Visible}"
                        />
                <DiscreteObjectKeyFrame
                    KeyTime="00:00:00.3000000" 
                    Value="{x:Static Visibility.Visible}"
                        />
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>

        <!-- Animation for hiding the Person Info control -->
        <Storyboard 
            x:Key="HidePersonInfo" 
            Completed="HidePersonInfo_StoryboardCompleted"
                >
            <DoubleAnimationUsingKeyFrames
                BeginTime="00:00:00" 
                Storyboard.TargetProperty="(UIElement.Opacity)"
                Storyboard.TargetName="PersonInfoControl"
                    >
                <SplineDoubleKeyFrame
                    KeyTime="00:00:00"
                    Value="1"
                        />
                <SplineDoubleKeyFrame
                    KeyTime="00:00:00.3000000" 
                    Value="0"
                        />
            </DoubleAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames
                BeginTime="00:00:00"
                Storyboard.TargetName="PersonInfoControl" 
                Storyboard.TargetProperty="(UIElement.Visibility)"
                    >
                <DiscreteObjectKeyFrame 
                    KeyTime="00:00:00" 
                    Value="{x:Static Visibility.Visible}"
                        />
                <DiscreteObjectKeyFrame 
                    KeyTime="00:00:00.3000000"
                    Value="{x:Static Visibility.Hidden}"
                        />
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>

        <!-- Animation for showing the Family Data control -->
        <Storyboard 
            x:Key="ShowFamilyData" 
            Completed="ShowFamilyData_StoryboardCompleted"
                >
            <DoubleAnimationUsingKeyFrames 
                BeginTime="00:00:00" 
                Storyboard.TargetName="FamilyDataControl" 
                Storyboard.TargetProperty="(UIElement.Opacity)"
                    >
                <SplineDoubleKeyFrame
                    KeyTime="00:00:00" 
                    Value="0"
                        />
                <SplineDoubleKeyFrame 
                    KeyTime="00:00:00.3000000"
                    Value="1"
                        />
            </DoubleAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames 
                BeginTime="00:00:00"
                Storyboard.TargetName="FamilyDataControl" 
                Storyboard.TargetProperty="(UIElement.Visibility)"
                    >
                <DiscreteObjectKeyFrame
                    KeyTime="00:00:00" 
                    Value="{x:Static Visibility.Visible}"
                        />
                <DiscreteObjectKeyFrame 
                    KeyTime="00:00:00.3000000" 
                    Value="{x:Static Visibility.Visible}"
                        />
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>

        <!-- Animation for hiding the Family Data control -->
        <Storyboard 
            x:Key="HideFamilyData" 
            Completed="HideFamilyData_StoryboardCompleted"
                >
            <DoubleAnimationUsingKeyFrames 
                BeginTime="00:00:00" 
                Storyboard.TargetProperty="(UIElement.Opacity)" 
                Storyboard.TargetName="FamilyDataControl"
                    >
                <SplineDoubleKeyFrame 
                    KeyTime="00:00:00" 
                    Value="1"
                        />
                <SplineDoubleKeyFrame 
                    KeyTime="00:00:00.3000000" 
                    Value="0"
                        />
            </DoubleAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames 
                BeginTime="00:00:00" 
                Storyboard.TargetName="FamilyDataControl" 
                Storyboard.TargetProperty="(UIElement.Visibility)"
                    >
                <DiscreteObjectKeyFrame 
                    KeyTime="00:00:00" 
                    Value="{x:Static Visibility.Visible}"
                        />
                <DiscreteObjectKeyFrame 
                    KeyTime="00:00:00.3000000" 
                    Value="{x:Static Visibility.Hidden}"
                        />
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>
    </Window.Resources>

    <!--Setup menu command bindings-->
    <Window.CommandBindings>
        <CommandBinding
            Command="ApplicationCommands.New" 
            Executed="NewFamily"
                />
        <CommandBinding
            Command="ApplicationCommands.Open" 
            Executed="OpenFamily"
                />
        <CommandBinding
            Command="ApplicationCommands.Save" 
            Executed="SaveFamily"
                />
        <CommandBinding 
            Command="ApplicationCommands.SaveAs" 
            Executed="SaveFamilyAs"
                />
        <CommandBinding 
            Command="ApplicationCommands.Print" 
            Executed="Print"
                />
    </Window.CommandBindings>

    <DockPanel>

        <!-- #Region Menu -->
        <Border
            Style="{DynamicResource MainWindowBorderMenuStyle}"
                >
            <Menu 
                Style="{DynamicResource MainWindowMenuStyle}"
                IsMainMenu="True"
                    >
                <MenuItem 
                    Header="{x:Static properties:Resources.MenuHeaderFile}" 
                    x:Name="OpenMenu"  
                    Command="Open"
                    Style="{DynamicResource MainWindowMenuItemStyle}"
                        >
                    <MenuItem
                        Header="{x:Static properties:Resources.NewMenu}" 
                        Command="New"
                            />
                    <MenuItem
                        Header="{x:Static properties:Resources.OpenMenu}" 
                        Command="Open" 
                        Icon="{StaticResource folderico}"
                            />
                    <MenuItem
                        Header="{x:Static properties:Resources.GedcomMenu}"
                        Click="ImportGedcom" 
                            />
                    <MenuItem 
                        Header="{x:Static properties:Resources.MergeMenu}" 
                        Click="Merge" 
                        Icon="{StaticResource mergeico}"
                            />
                </MenuItem>

                <MenuItem 
                    Header="{x:Static properties:Resources.MenuHeaderSave}"
                    x:Name="SaveMenu" 
                    Style="{DynamicResource MainWindowMenuItemStyle}" 
                    StaysOpenOnClick="True"
                        >
                    <MenuItem
                        Header="{x:Static properties:Resources.Save}"
                        Command="Save" 
                        Icon="{StaticResource saveico}"
                            />
                    <MenuItem
                        Header="{x:Static properties:Resources.SaveAsMenu}" 
                        Command="SaveAs"
                            />
                    <MenuItem
                        Header="{x:Static properties:Resources.ExportGedcomMenu}"  
                        Click="ExportGedcom" 
                            />
                    <MenuItem
                        Header="{x:Static properties:Resources.ExportHtmlMenu}"  
                        Click="ExportHtml"
                            />
                    <MenuItem
                        Header="{x:Static properties:Resources.ExportPlacesMenu}"  
                        Click="ExportPlaces"
                            />
                    <MenuItem
                        Header="{x:Static properties:Resources.ExtractFilesMenu}" 
                        Icon="{StaticResource extractico}" 
                        Click="ExtractFiles"
                            />
                </MenuItem>

                <MenuItem 
                    Header="{x:Static properties:Resources.MenuHeaderTools}" 
                    x:Name="MediaMenu" 
                    Style="{DynamicResource MainWindowMenuItemStyle}"
                        >
                    <MenuItem
                        Header="{x:Static properties:Resources.SourcesMenu}" 
                        Click="EditSources" 
                        Icon="{StaticResource sourceico}"
                            />
                    <MenuItem
                        Header="{x:Static properties:Resources.RepositoriesMenu}" 
                        Click="EditRepositories" 
                        Icon="{StaticResource repositoryico}"
                            />
                    <MenuItem
                        Header="{x:Static properties:Resources.StatisticsMenu}" 
                        Click="Statistics" 
                        Icon="{StaticResource statsico}"
                            />
                    <MenuItem
                        Header="{x:Static properties:Resources.DateCalculatorMenu}" 
                        Click="Dates" 
                        Icon="{StaticResource dateico}"
                            />
                    <MenuItem
                        Header="{x:Static properties:Resources.PhotosMenu}"
                        Click="Photos" 
                        Icon="{StaticResource photosico}"
                            />
                    <MenuItem
                        Header="{x:Static properties:Resources.AttachmentsMenu}" 
                        Click="Attachments" 
                        Icon="{StaticResource attachmentsico}"
                            />
                    <MenuItem
                        Header="{x:Static properties:Resources.StoriesMenu}" 
                        Click="Storys"
                        Icon="{StaticResource storiesico}"
                            />
                </MenuItem>

                <MenuItem 
                    Header="{x:Static properties:Resources.MenuHeaderPrint}" 
                    x:Name="PrintMenu"
                    Style="{DynamicResource MainWindowMenuItemStyle}"
                        >
                    <MenuItem
                        x:Name="shadowMenu" 
                        Header="Hide Shadows" 
                        Click="ShowShadows_Click"
                            />
                    <MenuItem
                        Header="{x:Static properties:Resources.PrintMenu}"
                        Command="Print" 
                        Icon="{StaticResource printico}"
                            />
                    <MenuItem
                        Header="{x:Static properties:Resources.PrintXPSMenu}"
                        Click="ExportXps"
                            />
                </MenuItem>

                <MenuItem
                    Header="{x:Static properties:Resources.MenuHeaderThemes}" 
                    x:Name="ThemesMenu" 
                    Style="{DynamicResource MainWindowMenuItemStyle}"
                        />
                <MenuItem
                    Header="{x:Static properties:Resources.MenuHeaderHelp}" 
                    x:Name="HelpMenu"
                    Style="{DynamicResource MainWindowMenuItemStyle}"
                        >
                    <MenuItem 
                        Header="{x:Static properties:Resources.LanguageMenu}" 
                        Click="Languages" 
                        Icon="{StaticResource languageico}"
                            />
                    <MenuItem
                        Header="{x:Static properties:Resources.AboutMenu}" 
                        Click="About"
                            />
                </MenuItem>
            </Menu>
        </Border>
        <!-- #EndRegion Menu -->

        <!-- #Region Content -->
        <Grid
            Style="{DynamicResource MainWindowContentGrid}"
                >

            <!-- #Region ImmediatellyVisibleControls -->
            <!-- TODO: Maybe Move ColDefs to Theme? -->
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <!-- Diagram Area -->
            <Grid
                Style="{DynamicResource MainWindowContentDiagram}"
                x:Name="DiagramPane"
                    >
                <Grid.ContextMenu>
                    <ContextMenu
                        Style="{DynamicResource MainWindowContentDiagramGrid_ContextMenu}" 
                            >
                        <MenuItem 
                            Style="{DynamicResource MainWindowContentDiagramContextMenuItem}"
                            x:Name="FullScreen"  
                            Unchecked="FullScreen_Unchecked" 
                            Checked="FullScreen_Checked" 
                            Header="{x:Static properties:Resources.FullScreen}" 
                            IsCheckable="True" 
                            IsChecked="False"
                                />
                        <MenuItem 
                            Style="{DynamicResource MainWindowContentDiagramContextMenuItem}"
                            x:Name="HideDiagramControls"  
                            Unchecked="HideControls_Unchecked" 
                            Checked="HideControls_Checked" 
                            Header="{x:Static properties:Resources.HideControls}"
                            IsCheckable="True" 
                            IsChecked="False"
                                />
                    </ContextMenu>
                </Grid.ContextMenu>
                <Grid.RowDefinitions>
                    <RowDefinition
                        Style="{DynamicResource MaintainContentDiagramGrid_RowDefinition1}" 
                            />
                    <RowDefinition 
                        Style="{DynamicResource MaintainContentDiagramGrid_RowDefinition2}" 
                            />
                </Grid.RowDefinitions>

                <Border 
                    Style="{DynamicResource MaintainContentDiagramGridBorder}"
                    x:Name="DiagramBorder" 
                        >
                    <local:DiagramViewer
                        x:Name="DiagramControl" 
                        Zoom="1.5"
                            />
                </Border>
            </Grid>

            <GridSplitter
                Style="{DynamicResource MainWindowContentDiagramGridSplitter}"
                    />
            
            <!-- Details Area -->
            <Grid
                Style="{DynamicResource MainWindowContentGrid_Details}"
                x:Name="DetailsPane"
                    >
                <local:Details 
                    Style="{DynamicResource MainWindowContentGridDetails}"
                    DataContext="{Binding}" 
                    x:Name="DetailsControl" 
                    PersonInfoClick="DetailsControl_PersonInfoClick" 
                    EveryoneDeleted="DetailsControl_EveryoneDeleted" 
                    FamilyDataClick="DetailsControl_FamilyDataClick" 
                        />
            </Grid>
            <!-- #EndRegion ImmediatellyVisibleControls -->

            <!-- #Region InvisibleControls -->

            <!-- New User Control -->
            <Controls:NewUserControl 
                Style="{DynamicResource MainWindowGridContentNewUserControl}"
                x:Name="NewUserControl"
                AddButtonClick="NewUserControl_AddButtonClick"
                CancelButtonClick="NewUserControl_CancelButtonClick"
                    />

            <!-- Welcome User Control -->
            <local:Welcome 
                Style="{DynamicResource MainWindowGridContentWelcomeUserControl}"
                x:Name="WelcomeUserControl" 
                ImportButtonClick="WelcomeUserControl_ImportButtonClick" 
                NewButtonClick="WelcomeUserControl_NewButtonClick" 
                OpenButtonClick="WelcomeUserControl_OpenButtonClick" 
                OpenRecentFileButtonClick="WelcomeUserControl_OpenRecentFileButtonClick" 
                    />

            <!-- About Control -->
            <Controls:About 
                Style="{DynamicResource MainWindowGridContentAboutControl}"
                x:Name="AboutControl" 
                CloseButtonClick="AboutControl_CloseButtonClick" 
                    />

            <!-- Statistics Control -->
            <local:Statistics 
                Style="{DynamicResource MainWindowGridContentStatisticsControl}"
                x:Name="StatisticsControl" 
                CloseButtonClick="StatisticsControl_CloseButtonClick" 
                    />

            <!-- PhotoViewer Control -->
            <local:PhotoViewer 
                Style="{DynamicResource MainWindowGridContentPhotoViewerControl}"
                x:Name="PhotoViewerControl"
                CloseButtonClick="PhotoViewerControl_CloseButtonClick" 
                    />

            <!-- AttachmentViewer Control -->
            <local:AttachmentViewer 
                Style="{DynamicResource MainWindowGridContentAttachmentViewerControl}"
                x:Name="AttachmentViewerControl" 
                CloseButtonClick="AttachmentViewerControl_CloseButtonClick" 
                    />

            <!-- StoryViewer Control -->
            <local:StoryViewer 
                Style="{DynamicResource MainWindowGridContentStoryViewerControl}"
                x:Name="StoryViewerControl" 
                CloseButtonClick="StoryViewerControl_CloseButtonClick" 
                    />

            <!-- Merge Control -->
            <local:Merge 
                Style="{DynamicResource MainWindowGridContentMergeControl}"
                x:Name="MergeControl" 
                DoneButtonClick="MergeControl_DoneButtonClick"
                    />

            <!-- Save Control -->
            <local:Save 
                Style="{DynamicResource MainWindowGridContentSaveControl}"
                x:Name="SaveControl" 
                SaveButtonClick="SaveControl_SaveButtonClick" 
                CancelButtonClick="SaveControl_CancelButtonClick"
                    />

            <!-- Extract Control -->
            <local:Extract 
                Style="{DynamicResource MainWindowGridContentExtractControl}"
                x:Name="ExtractControl"
                CancelButtonClick="ExtractControl_CancelButtonClick" 
                    />

            <!-- PersonInfo Control -->
            <local:PersonInfo 
                Style="{DynamicResource MainWindowGridContentPersonInfoControl}"
                x:Name="PersonInfoControl" 
                CloseButtonClick="PersonInfoControl_CloseButtonClick" 
                    />

            <!-- Html Control -->
            <local:Html 
                Style="{DynamicResource MainWindowGridContentHtmlControl}"
                x:Name="HtmlControl" 
                CancelButtonClick="HtmlControl_CancelButtonClick"
                    />

            <!-- Places Control -->
            <local:Places 
                Style="{DynamicResource MainWindowGridContentPlacesControl}"
                x:Name="PlacesControl" 
                CancelButtonClick="PlacesControl_CancelButtonClick"
                    />

            <!-- GedcomLocalization Control -->
            <local:GedcomLocalization
                Style="{DynamicResource MainWindowGridContentGedcomLocalizationControl}"
                x:Name="GedcomLocalizationControl"
                ContinueButtonClick="GedcomLocalizationControl_ContinueButtonClick"
                CancelButtonClick="GedcomLocalizationControl_CancelButtonClick"
                    />

            <!-- Sources Control -->
            <local:Sources 
                Style="{DynamicResource MainWindowGridContentSourcesControl}"
                x:Name="SourcesControl" 
                CancelButtonClick="SourcesControl_CancelButtonClick"
                    />

            <!-- Repositories Control -->
            <local:Repositories 
                Style="{DynamicResource MainWindowGridContentRepositoriesControl}"
                x:Name="RepositoriesControl" 
                CancelButtonClick="RepositoriesControl_CancelButtonClick" 
                    />

            <!-- FamilyData Control -->
            <local:FamilyData 
                Style="{DynamicResource MainWindowGridContentFamilyDataControl}"
                x:Name="FamilyDataControl" 
                CloseButtonClick="FamilyDataControl_CloseButtonClick" 
                    />

            <!-- Language Control -->
            <local:Language 
                Style="{DynamicResource MainWindowGridContentLanguageControl}"
                x:Name="LanguageControl" 
                CloseButtonClick="LanguageControl_CloseButtonClick" 
                    />

            <!--Date Calculator Control-->
            <local:DateCalculator
                Style="{DynamicResource MainWindowGridContentDateCalculatorControl}"
                x:Name="DateCalculatorControl" 
                CancelButtonClick="DateCalculatorControl_CancelButtonClick" 
                    />

            <!-- #EndRegion InvisibleControls -->

        </Grid>
        <!-- #EndRegion Content -->

    </DockPanel>

</Window>
